﻿@model LbangCMS.ViewModels.NewsListModel
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section head{
    <link href="~/Content/laypage/skin/laypage.css" rel="stylesheet" />
    }
@{ Html.RenderPartial("_InnerBanner");}

<div class="gx_p_content container">
    <div class="row">
        @{ Html.RenderAction("CategoryList","News", new { categoryId =(int) ViewBag.CategoryId }); }
     </div>
    <div class="gx_p_content_right am-animation-scale-up" data-am-scrollspy="{animation: 'scale-up'}">
        <div class="gx_p_right_top">
            <div class="gx_p_right_title">
                <strong class="gx_p_right_name">@ViewBag.CategoryName</strong><span class="gx_p_right_letter"><i class="fa icon_small"></i></span>
            </div>
            <div class="gx_p_right_position hidden-in">
                <i class="fa icon-position"></i><a href="@Url.Action("Index","Home")">首页</a>><a href="@Url.Action("Index","News",new { categoryId=ViewBag.CategoryId })">@ViewBag.CategoryName </a>
            </div>
        </div>
        <div class="gx_p_right_main">
            @if (Model.News != null && Model.News.Any())
            {
                foreach (var item in Model.News)
                {
                    <div class="gx_p_right_list" data-am-scrollspy="{animation: 'fade'}">
                        <div class="gx_p_right_list_text">
                            <h3 class="gx_p_list_tittle"><a href="@Url.Action("Detail","News",new { id=item.ID })">@item.Title</a></h3>
                            <p class="gx_p_list_main"><a href="@Url.Action("Detail","News",new { id=item.ID })">@item.Summary</a><a class="news_details" href="@Url.Action("Detail","News",new { id=item.ID })">【详情】</a></p>
                            <span class="gx_p_list_time">@item.PublishTime</span>
                        </div>
                        <a class="gx_p_list_img" href="news_details.html"><img src="@item.ConverSrc" alt="" /></a>
                    </div>
                }
                <div id="pager" class="gx_p_right_more hidden-in" data-am-scrollspy="{animation: 'fade'}">
                   
                </div>
                <div class="gx_p_right_more hidden-lg" data-am-scrollspy="{animation: 'fade'}"><a class="gx_p_right_more_on" href="@Url.Action("Index","News",new { categoryId=ViewBag.CategoryId,pageIndex=Model.PageIndex+1,pageSize= (Model.PageIndex+1)*5 })">查看更多>></a></div>
            }
        </div>
    </div>
</div>
@section script{
<script src="~/Content/laypage/laypage.js"></script>
    <script>
        var totalPage=@Model.TotalPage
        laypage({
            cont: 'pager',
            pages: totalPage, //可以叫服务端把总页数放在某一个隐藏域，再获取。假设我们获取到的是18
            curr: function () { //通过url获取当前页，也可以同上（pages）方式获取
                var page = location.search.match(/pageIndex=(\d+)/);
                return page ? page[1] : 1;
            }(),
            jump: function (e, first) { //触发分页后的回调
                if (!first) { //一定要加此判断，否则初始时会无限刷新
                    location.href = '?pageIndex=' + e.curr;
                }
            }
        });
    </script>
}
